# config:utf-8
from handle.login_handle import LoginHandle
from time import sleep
import sys

class LoginBusiness:
    def __init__(self, i):
        self.login_handle = LoginHandle(i)
        self.driver = self.login_handle.login_page.driver
        self.imgs = []
    def login_pass(self):
        self.imgs.append(self.driver.get_screenshot_as_base64())
        self.login_handle.to_login()
        self.imgs.append(self.driver.get_screenshot_as_base64())
        self.login_handle.send_username("18559651669")
        self.login_handle.click_next()
        sleep(5)
        self.login_handle.send_password("123456")
        self.imgs.append(self.driver.get_screenshot_as_base64())
        self.login_handle.click_login()
        self.imgs.append(self.driver.get_screenshot_as_base64())
    def user_error(self):
        self.login_handle.to_login()
        self.login_handle.send_username("9999999")
        self.login_handle.click_next()
        user_flag = self.login_handle.get_fail_tost("手机号码格式错误")
        if user_flag:
            return True
        else:
            return False

    def password_error(self):
        self.login_handle.to_login()
        self.login_handle.send_username("18559651669")
        self.login_handle.click_next()
        self.login_handle.send_password("12345677")
        self.login_handle.back_button()
        password_flag = self.login_handle.get_fail_tost("密码错误")
        if password_flag:
           return True
        else:
           return False
